package com.edar.model;

// Generated 2008-10-24 9:29:06 by Hibernate Tools 3.2.1.GA

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

/**
 * Role generated by hbm2java
 */
@Entity
public class Role implements java.io.Serializable {
	private static final long serialVersionUID = -7334948046448954828L;
	private Long roleId;
	private String code;
	private String name;
	private Set<Account> accounts = new HashSet<Account>(0);
	private Set<Auth> authes = new HashSet<Auth>(0);

	public Role() {
	}

	public Role(Long roleId) {
		this.roleId = roleId;
	}

	public Role(Long roleId, String code, String name, Set<Account> accounts, Set<Auth> authes) {
		this.roleId = roleId;
		this.code = code;
		this.name = name;
		this.accounts = accounts;
		this.authes = authes;
	}
	@Column(name="roleid")
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	public Long getRoleId() {
		return this.roleId;
	}

	public void setRoleId(Long roleId) {
		this.roleId = roleId;
	}

	public String getCode() {
		return this.code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}
	@ManyToMany(targetEntity=Account.class,cascade={CascadeType.PERSIST,CascadeType.MERGE})
	@JoinTable(name="account_role_rela",
			joinColumns=@JoinColumn(name="roleid"))
	
	
	public Set<Account> getAccounts() {
		return this.accounts;
	}

	public void setAccounts(Set<Account> accounts) {
		this.accounts = accounts;
	}
	@ManyToMany(targetEntity=Auth.class,cascade={CascadeType.PERSIST,CascadeType.MERGE})
	@JoinTable(name="role_auth_rela",
			joinColumns=@JoinColumn(name="roleid"))
	
	public Set<Auth> getAuthes() {
		return authes;
	}

	public void setAuthes(Set<Auth> authes) {
		this.authes = authes;
	}

}
